import React from 'react'

class FetchListComponent extends React.Component {

    constructor(props) {
        super(props)
    }

    componentDidMount() {
        const params = this.props.params
        const list = this.props.list
        const fetchList = this.props.fetchList
        if (fetchList && list.length === 0) {
            this.props.fetchList(params)
        }
    }

    componentWillUnmount() {
        if (this.props.unmountMethod) {
            this.props.unmountMethod()
        }

    }

    render() {
        return this.props.render(this.props.list)
    }

}

export default FetchListComponent
